package com.xinheyun.demo.leetcode;

import java.util.ArrayDeque;
import java.util.Deque;

/**
 * @description: TODO
 * @author: Sarah
 * @modified By: Sarah
 * @date: Created in 2021/8/8 19:05
 * @version:v1.0
 */
public class test09 {

}

class CQueue {

    Deque<Integer> stackIn;
    Deque<Integer> stackOut;

    public CQueue() {
        stackIn = new ArrayDeque<>();
        stackOut = new ArrayDeque<>();
    }

    public void appendTail(int value) {
        stackIn.push(value);
    }

    public int deleteHead() {
        if(!stackOut.isEmpty()){
            return stackOut.pop();
        }
        if(!stackIn.isEmpty()){
            while(!stackIn.isEmpty()){
                stackOut.push(stackIn.pop());
            }
            return stackOut.pop();
        }
        return -1;
    }
}

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue obj = new CQueue();
 * obj.appendTail(value);
 * int param_2 = obj.deleteHead();
 */